

<template tag="以下文档内容为hycli自动生成">
  <el-dialog
    v-model="conf.visible"
    
    :title="title"
    :width="conf.width"
    draggable
    align-center="true"
    :close-on-click-modal="false"
  >
<el-form :model="form"  ref="form" :rules="rules_aabbr">
    <el-row>
    <el-col :span="12">
    <!-- {"index":21,"raw":"start_date","name":"start_date","cname":"StartDate","type":{"raw":"date","name":"date","len":0,"dlen":0},"defValue":"","allowNull":false,"constraints":["l","le","q","c","v","u","tp(daterange,q)","tp(date,c-u)","f(yyyy/MM/dd)","lw(80)"],"desc":{"raw":"开始日期","name":"开始日期"}} -->
    <!--开始日期 日期控件 -->
    <el-form-item prop="start_date" label="开始日期" label-width="100px" label-position="right">
      <el-date-picker style="width: 100%" v-model="form.start_date" clearable type="date"
          placeholder="请选择开始日期" format="YYYY-MM-DD" value-format="YYYY-MM-DD"  :default-time="new Date($theia.str.dateFormat(new Date(),'yyyy/MM/dd'))"/>
    </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":22,"raw":"end_date","name":"end_date","cname":"EndDate","type":{"raw":"date","name":"date","len":0,"dlen":0},"defValue":"","allowNull":false,"constraints":["c","le","v","u","tp(date,c-u)","f(yyyy/MM/dd)","lw(80)"],"desc":{"raw":"结束日期","name":"结束日期"}} -->
    <!--结束日期 日期控件 -->
    <el-form-item prop="end_date" label="结束日期" label-width="100px" label-position="right">
      <el-date-picker style="width: 100%" v-model="form.end_date" clearable type="date"
          placeholder="请选择结束日期" format="YYYY-MM-DD" value-format="YYYY-MM-DD"  :default-time="new Date($theia.str.dateFormat(new Date(),'yyyy/MM/dd'))"/>
    </el-form-item>
    </el-col>
    <el-col :span="24">
    <!-- {"index":23,"raw":"report_content","name":"report_content","cname":"ReportContent","type":{"raw":"text","name":"text","len":0,"dlen":0},"defValue":"","allowNull":true,"constraints":["l","le","c","q","v","u","rows(12)"],"desc":{"raw":"内容","name":"内容"}} -->
    <!--内容 输入控件 -->
    <el-form-item prop="report_content" label="内容" label-width="100px" label-position="right">
      <el-input clearable style="width: 100%" v-model="form.report_content" 
      :rows="12"  type="textarea" show-word-limit  placeholder="请输入内容"  />
      </el-form-item>
    </el-col>
    <el-col :span="24">
    <!-- {"index":24,"raw":"feedback_content","name":"feedback_content","cname":"FeedbackContent","type":{"raw":"text","name":"text","len":0,"dlen":0},"defValue":"","allowNull":true,"constraints":["c","le","v","u","rows(4)"],"desc":{"raw":"反馈","name":"反馈"}} -->
    <!--反馈 输入控件 -->
    <el-form-item prop="feedback_content" label="反馈" label-width="100px" label-position="right">
      <el-input clearable style="width: 100%" v-model="form.feedback_content" 
      :rows="4"  type="textarea" show-word-limit  placeholder="请输入反馈"  />
      </el-form-item>
    </el-col>
    <el-col :span="24">
    <!-- {"index":25,"raw":"report_to_user","name":"report_to_user","cname":"ReportToUser","type":{"raw":"varchar(255)","name":"varchar","len":255,"dlen":0},"defValue":"","allowNull":true,"constraints":["l","c","le","v","u","sl(user_account)","tp(multiselect)"],"desc":{"raw":"汇报给","name":"汇报给"}} -->
    <!--汇报给 多选控件 --> 
    <el-form-item prop="report_to_user" label="汇报给" label-width="100px" label-position="right">
      <el-select style="width: 100%"   v-model="form.report_to_user" clearable multiple 
      collapse-tags-tooltip
        placeholder="请选择汇报给">
        <el-option v-for="item in report_to_userList" :key="item.value" :label="item.name" :value="item.value" />
      </el-select>
    </el-form-item>
    </el-col>
    <el-col :span="24">
    <!-- {"index":26,"raw":"cc_users","name":"cc_users","cname":"CcUsers","type":{"raw":"varchar(255)","name":"varchar","len":255,"dlen":0},"defValue":"","allowNull":true,"constraints":["c","le","v","u","sl(user_account)","tp(multiselect)"],"desc":{"raw":"抄送用户","name":"抄送用户"}} -->
    <!--抄送用户 多选控件 --> 
    <el-form-item prop="cc_users" label="抄送用户" label-width="100px" label-position="right">
      <el-select style="width: 100%"   v-model="form.cc_users" clearable multiple 
      collapse-tags-tooltip
        placeholder="请选择抄送用户">
        <el-option v-for="item in cc_usersList" :key="item.value" :label="item.name" :value="item.value" />
      </el-select>
    </el-form-item>
    </el-col>
    </el-row>
</el-form>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="hide" icon="close">取消</el-button>
        <el-button type="primary" @click="save" icon="select">提交</el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script>
import rtext from "@/views/cmpnts/rtext.vue"
export default {
  components: {
    rtext
},
  data() {
    return {
      conf: {
        visible: false,
        width:"60%",
        uploadPath:this.$theia.env.join("/file/upload"),
      },
      title:"修改周报",
rules_aabbr:{
    start_date:[{required:true,message:"请输入开始日期",trigger: 'blur'}],
    end_date:[{required:true,message:"请输入结束日期",trigger: 'blur'}],
    report_content:[{required:false,message:"请输入内容",trigger: 'blur'}],
    feedback_content:[{required:false,message:"请输入反馈",trigger: 'blur'}],
    report_to_user:[{required:false,message:"请输入汇报给",trigger: 'blur'}],
    cc_users:[{required:false,message:"请输入抄送用户",trigger: 'blur'}],
  },
    form:{
        start_date:"",
        end_date:"",
        report_content:"",
        feedback_content:"",
        report_to_user:[],
        cc_users:[],
    },
    report_to_userList:[],
    cc_usersList:[],
    }
  },
  methods: {
    show(form) {
      this.conf.visible = true;
      this.loadEnums_aabbr()
      this.form = Object.assign(form,this.$route.params)
      this.get(form)
    },
      get(form){
        let that = this
        this.conf.loading = true
        let postForm = {}
        postForm.wr_id = form.wr_id
        this.$theia.http.get("/ws/weekly/report",postForm).then(res=>{
          res.report_to_user = (res.report_to_user+"").split(",")
          res.cc_users = (res.cc_users+"").split(",")
          that.form = Object.assign(that.form, res)
        //处理枚举重新绑定
          this.loadEnums_aabbr()
          that.conf.loading = false
        }).catch(res=>{
          let code = ((res||{}).response||{}).status||0
          let msg = `周报查询失败(${code})`
          that.$notify.error({title: '失败',message:msg ,duration:5000})
        })
    },
    save(){
        this.$refs.form.validate((v=>{
            if(v) this.onSave()
        }))
    },
    onSave(){
      let that = this
        let postForm = Object.assign({},this.form)
        postForm.report_to_user = (postForm.report_to_user||[]).join(",")
        postForm.cc_users = (postForm.cc_users||[]).join(",")
        this.$theia.http.put("/ws/weekly/report",postForm).then(res=>{
            that.$notify.success({title: '成功',message: '周报保存成功',duration:5000})
            that.hide()
            that.$emit("onsaved")
        }).catch(res=>{
            let code = ((res||{}).response||{}).status||0
            let msg = `周报修改失败(${code})`
            that.$notify.error({title: '失败',message: msg,duration:5000})
        })
    },
    hide() {
      this.conf.visible = false;
      this.$refs.form.resetFields();
    },
     onUploadSuccess(response){
    },
    loadEnums_aabbr(){
        //汇报给
        this.report_to_userList = this.$theia.enum.get("user_account","","" ,false,"")
        //抄送用户
        this.cc_usersList = this.$theia.enum.get("user_account","","" ,false,"")
    },

  },
};
</script>

<style scoped>
.form_item_info{
  margin-left: 4px;
  color:#999;
}
.form_item_info:hover{
  cursor: pointer;
  font-weight: 500;
  color:#333;
}
</style>